#ifndef GAME_H
#define GAME_H

#include "OpenGLRenderer.h"
#include "TextureHandler.h"
#include "Input.h"
#include "Timer.h"
#include "Camera.h"
#include "World.h"
#include "Maths.h"
#include "String.h"

#define MOD_PATH "mods/"
#define ENTITIES_PATH "entities/"
#define LEVELS_PATH "levels/"
#define TEXTURE_EXT ".png"

//TODO: Add collider class
//      Types of colliders: circle, mask
//      Think about how to allow separate points as well as entities Replace Vector vPos with Point* or Vector* in Entity
//      Implement slide constraints
//      Implement cubic spline constraints
//      Think about how best to make a skeletal animation system

class CGame
{
    
public:
    
    //Returns singleton instance
    static CGame* getInstance()
    {
        if (!s_pInstance)
            s_pInstance = new CGame();
        return s_pInstance;
    }
    
    void init(int iWidth, int iHeight, int iBits, bool bFullscreen);
    void start(String sModName, String sLevelName, int iPlayerCount);
    void cleanup();
    
    CTextureHandler*    getTextureHandler()     { return m_pTextureHandler; }
    CWorld*             getWorld()              { return m_pWorld; }
    
    String getModPath()         { return MOD_PATH + m_sCurModName + "/"; }
    
private:
    
    CGame() : m_fGameSpeed(1), m_pRenderer(0), m_pTextureHandler(0), m_pInput(0), m_pTimer(0), m_pCamera(0), m_pWorld(0)
    {
        
    }
    
    ~CGame()
    {
        cleanup();
    }
    
    static CGame* s_pInstance;
    
    //Game engine components
    CRenderer*          m_pRenderer;
    CTextureHandler*    m_pTextureHandler;
    CInput*             m_pInput;
    CTimer*             m_pTimer;
    C2DCamera*          m_pCamera;
    CWorld*             m_pWorld;
    
    String m_sCurModName;
    Scalar m_fGameSpeed;
    
};

#endif //GAME_H
